import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class RankedGUI extends JFrame {

	private JPanel contentPane;
	private int x = 0, win1 = 0, win2 = 0, win3 = 0, win4 = 0, wal1 = 0, wal2 = 0, wal3 = 0, wal4 = 0;
	private String[] namesLabel = new String[4];
	Table T;
	/**
	 * Create the frame.
	 */
	RankedGUI(String[] names, Player[] PlayerTab, int[] winTab, int[] walletTab, Table T) {
		setResizable(false);
		
		this.T =T;
		setTitle("Poker - Ranking");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(450, 200, 450, 275);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblRanking = new JLabel("Ranking");
		lblRanking.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblRanking.setHorizontalAlignment(SwingConstants.CENTER);
		lblRanking.setBounds(137, 11, 128, 25);
		contentPane.add(lblRanking);
		
		JLabel lblPlayer = new JLabel("Player");
		lblPlayer.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPlayer.setBounds(91, 56, 46, 14);
		contentPane.add(lblPlayer);
		
		JLabel lblWins = new JLabel("Wins");
		lblWins.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblWins.setBounds(204, 56, 46, 14);
		contentPane.add(lblWins);
		
		JLabel lblAktualWallet = new JLabel("Actual Wallet");
		lblAktualWallet.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblAktualWallet.setBounds(273, 56, 90, 14);
		contentPane.add(lblAktualWallet);
		
		JLabel label = new JLabel("1.");
		label.setBounds(55, 81, 10, 14);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("2.");
		label_1.setBounds(55, 106, 10, 14);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("3.");
		label_2.setBounds(55, 129, 10, 14);
		contentPane.add(label_2);
		
		JLabel label_3 = new JLabel("4.");
		label_3.setBounds(55, 154, 10, 14);
		contentPane.add(label_3);
		
		
		for(int i=0;i<4;i++) 
		{
			if(PlayerTab[i]!=null)
				namesLabel[i] = PlayerTab[i].x;
			else 
				namesLabel[i]="";
		}
		
		win1 = winTab[0];
		win2 = winTab[1];
		win3 = winTab[2];
		win4 = winTab[3];
		
		JLabel Name1Label = new JLabel(names[0]+"("+namesLabel[0]+")");
		Name1Label.setBounds(75, 81, 122, 14);
		contentPane.add(Name1Label);
		
		JLabel Name2Label = new JLabel(names[1]+"("+namesLabel[1]+")");
		Name2Label.setBounds(75, 106, 122, 14);
		contentPane.add(Name2Label);
		
		JLabel Name3Label = new JLabel(names[2]+"("+namesLabel[2]+")");
		Name3Label.setBounds(75, 129, 122, 14);
		contentPane.add(Name3Label);
		
		JLabel Name4Label = new JLabel(names[3]+"("+namesLabel[3]+")");
		Name4Label.setBounds(75, 154, 122, 14);
		contentPane.add(Name4Label);
		
		JLabel Wins1Label = new JLabel(""+win1);
		Wins1Label.setBounds(216, 81, 23, 14);
		contentPane.add(Wins1Label);
		
		JLabel Wins3Label = new JLabel(""+win3);
		Wins3Label.setBounds(216, 129, 26, 14);
		contentPane.add(Wins3Label);
		
		JLabel Wins4Label = new JLabel(""+win4);
		Wins4Label.setBounds(216, 154, 26, 14);
		contentPane.add(Wins4Label);
		
		JLabel Wins2Label = new JLabel(""+win2);
		Wins2Label.setBounds(216, 106, 23, 14);
		contentPane.add(Wins2Label);
		
		wal1 = walletTab[0];
		wal2 = walletTab[1];
		wal3 = walletTab[2];
		wal4 = walletTab[3];
		
		JLabel Wallet1Label = new JLabel(""+wal1);
		Wallet1Label.setHorizontalAlignment(SwingConstants.TRAILING);
		Wallet1Label.setBounds(261, 81, 90, 14);
		contentPane.add(Wallet1Label);
		
		JLabel Wallet2Label = new JLabel(""+wal2);
		Wallet2Label.setHorizontalAlignment(SwingConstants.TRAILING);
		Wallet2Label.setBounds(261, 106, 90, 14);
		contentPane.add(Wallet2Label);
		
		JLabel Wallet3Label = new JLabel(""+wal3);
		Wallet3Label.setHorizontalAlignment(SwingConstants.TRAILING);
		Wallet3Label.setBounds(261, 129, 90, 14);
		contentPane.add(Wallet3Label);
		
		JLabel Wallet4Label = new JLabel(""+wal4);
		Wallet4Label.setHorizontalAlignment(SwingConstants.TRAILING);
		Wallet4Label.setBounds(261, 154, 90, 14);
		contentPane.add(Wallet4Label);
		
		JButton NewRoundButton = new JButton("New Round!");
		NewRoundButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				getTable().notifier();
			}
		});
		NewRoundButton.setBounds(153, 191, 104, 23);
		contentPane.add(NewRoundButton);
	}
	
	public void killMe()
	{
		setVisible(false);
	}
	public Table getTable()
	{
		return this.T;
	}

}
